<!--提供方管理页面-->
<style>
    .grid-content {
        margin-bottom: 20px;
        min-height: 36px;
    }
</style>
<template>
    <div>
        <card>
            <br/>接口总数：{{allServiceNum}}
            <br/>提供方总数：{{allProviderNum}}
            <br/>请求方总数：{{allRequesterNum}}
            <br/>历史调用次数：{{allInvoLogNum}}
            <br/>今日调用次数：{{todayInvoLogNum}}
            <br/>总成功调用次数：{{allSuccInvoNum}}
            <br/>总失败调用次数：{{allFailInvoNum}}
            <br/>今日成功次数：{{todaySuccInvoNum}}
            <br/>今日失败次数：{{todayFailInvoNum}}
        </card>
        <el-col :span="12">
            每个接口的总调用次数列表：
            <!--列表、table-->
            <el-table :data="countAllServiceDate" border stripe style="width: 100%">
                <el-table-column type="index" label="序号" width="50"></el-table-column>
                    <el-table-column prop="serialNo" label="接口标识" width="200"></el-table-column>
                    <el-table-column prop="name" label="接口名称" width="200"></el-table-column>
                    <el-table-column prop="path" label="接口地址" width="200"></el-table-column>
                    <el-table-column prop="count" label="数量" width="100"></el-table-column>
            </el-table>
             <!--分頁插件-->
            <el-col :span="12" class="toolbar">
                <el-pagination layout="total, prev, pager, next, jumper" @current-change="handleCurrentPageChange_all"
                                :current-page="allServicePageNum"
                                :page-size="allServicePageSize" :total="allServiceTotal">
                </el-pagination>
            </el-col>
        </el-col>
        
        <el-col :span="12">
            每个接口今日调用次数列表：
            <!--列表、table-->
            <el-table :data="countTodayServiceDate" border stripe style="width: 100%">
                <el-table-column type="index" label="序号" width="50"></el-table-column>
                    <el-table-column prop="serialNo" label="接口标识" width="200"></el-table-column>
                    <el-table-column prop="name" label="接口名称" width="200"></el-table-column>
                    <el-table-column prop="path" label="接口地址" width="200"></el-table-column>
                    <el-table-column prop="count" label="数量" width="100"></el-table-column>
            </el-table>
            <!--分頁插件-->
            <el-col :span="12" class="toolbar">
                <el-pagination layout="total, prev, pager, next, jumper" @current-change="handleCurrentPageChange_today"
                                :current-page="todayServicePageNum"
                                :page-size="todayServicePageSize" :total="todayServiceTotal">
                </el-pagination>
            </el-col>
        </el-col>
    </div>
</template>
<script>

    import {invoLog_countByCondition, pro_countByCondition, req_countByCondition, ser_countByCondition,ser_countAllService,ser_countTodayService} from '../api/api.js';
    import utils from '../api/utils.js';

    export default {
        data() {
            return {
                allServiceNum:0,// 所有接口总数
                allInvoLogNum:0,// 所有调用日志数量
                allRequesterNum:0,// 所有请求者数量
                allProviderNum:0,// 所有提供者数量
                todayInvoLogNum:0,// 今日调用日志数量
                allSuccInvoNum:0,// 所有调用成功的数量
                allFailInvoNum:0,// 所有调用失败的数量
                todaySuccInvoNum:0,// 今日成功次数
                todayFailInvoNum:0,// 今日失败次数

                countAllServiceDate: [],
                allServicePageNum:1,
                allServicePageSize:10,
                allServiceTotal:0,

                countTodayServiceDate: [],
                todayServicePageNum:1,
                todayServicePageSize:10,
                todayServiceTotal:0,
            };
        },
        methods: {
            formatCommDatas(row, column){
                return utils.formatCommDatas(row,column);
            },
            get_ser_countAllService_list(){
                let params = {
					pageNum: this.allServicePageNum,
					pageSize: this.allServicePageSize
				};
				//NProgress.start();
				ser_countAllService(params).then(function(result){
                    this.countAllServiceDate = result.data.list;
					this.allServicePageNum = result.data.pageNum;
					this.allServicePageSize = result.data.pageSize;
					this.allServiceTotal = result.data.total;
				}.bind(this)).catch(function (error) {
					console.log(error);
				}.bind(this));
            },
            handleCurrentPageChange_all: function (pageNum) {// 翻页动作
                this.allServicePageNum = pageNum;
                this.get_ser_countAllService_list();// 翻页后刷新页面数据
			},
            get_ser_countTodayService_list(){
                let params = {
					pageNum: this.todayServicePageNum,
					pageSize: this.todayServicePageSize
				};
				//NProgress.start();
				ser_countTodayService(params).then(function(result){
					this.countTodayServiceDate = result.data.list;
					this.todayServicePageNum = result.data.pageNum;
					this.todayServicePageSize = result.data.pageSize;
					this.todayServiceTotal = result.data.total;
				}.bind(this)).catch(function (error) {
					console.log(error);
				}.bind(this));
            },
            handleCurrentPageChange_today: function (pageNum) {// 翻页动作
                this.todayServicePageNum = pageNum;
                this.get_ser_countTodayService_list();// 翻页后刷新页面数据
			},
        },
        computed: {

        },
        created() {
            let _this = this;

            ser_countByCondition({}).then(res => {// 所有接口总数
                if(res.data.code!='S100101'){
                    console.log(res.data);
                    this.$message.warning('系统异常 ');
                }else{_this.allServiceNum=res.data.data}
            }).catch(function (error) {
                console.log(error);
                this.$message.warning('系统异常 ');
            });

            pro_countByCondition({}).then(res => {// 所有提供者数量
                if(res.data.code!='S100101'){
                    console.log(res.data);
                    this.$message.warning('系统异常 ');
                }else{_this.allProviderNum=res.data.data}
            }).catch(function (error) {
                console.log(error);
                this.$message.warning('系统异常 ');
            });

            req_countByCondition({}).then(res => {// 所有请求者数量
                if(res.data.code!='S100101'){
                    console.log(res.data);
                    this.$message.warning('系统异常 ');
                }else{_this.allRequesterNum=res.data.data}
            }).catch(function (error) {
                console.log(error);
                this.$message.warning('系统异常 ');
            });


            invoLog_countByCondition({}).then(res => {// 所有调用日志数量
                if(res.data.code!='S100101'){
                    console.log(res.data);
                    this.$message.warning('系统异常 ');
                }else{_this.allInvoLogNum=res.data.data}
            }).catch(function (error) {
                console.log(error);
                this.$message.warning('系统异常 ');
            });


            invoLog_countByCondition({"startTime":new Date(),"endTime":new Date()}).then(res => {// 今日调用日志数量
                if(res.data.code!='S100101'){
                    console.log(res.data);
                    this.$message.warning('系统异常 ');
                }else{_this.todayInvoLogNum=res.data.data}
            }).catch(function (error) {
                console.log(error);
                this.$message.warning('系统异常 ');
            });


            invoLog_countByCondition({"resultStatus":1}).then(res => {// 总成功调用次数
                if(res.data.code!='S100101'){
                    console.log(res.data);
                    this.$message.warning('系统异常 ');
                }else{_this.allSuccInvoNum=res.data.data}
            }).catch(function (error) {
                console.log(error);
                this.$message.warning('系统异常 ');
            });

            invoLog_countByCondition({"resultStatus":0}).then(res => {// 总失败调用次数
                if(res.data.code!='S100101'){
                    console.log(res.data);
                    this.$message.warning('系统异常 ');
                }else{_this.allFailInvoNum=res.data.data}
            }).catch(function (error) {
                console.log(error);
                this.$message.warning('系统异常 ');
            });

            invoLog_countByCondition({"resultStatus":1,"startTime":new Date(),"endTime":new Date()}).then(res => {// 今日成功次数
                if(res.data.code!='S100101'){
                    console.log(res.data);
                    this.$message.warning('系统异常 ');
                }else{_this.todaySuccInvoNum=res.data.data}
            }).catch(function (error) {
                console.log(error);
                this.$message.warning('系统异常 ');
            });

            invoLog_countByCondition({"resultStatus":0,"startTime":new Date(),"endTime":new Date()}).then(res => {// 今日失败次数
                if(res.data.code!='S100101'){
                    console.log(res.data);
                    this.$message.warning('系统异常 ');
                }else{_this.todayFailInvoNum=res.data.data}
            }).catch(function (error) {
                console.log(error);
                this.$message.warning('系统异常 ');
            });





        },
        mounted(){
            this.get_ser_countAllService_list();
            this.get_ser_countTodayService_list();
        }


    };
</script>
 
